package entity

import (
	"github.com/emirpasic/gods/maps"
	"github.com/emirpasic/gods/maps/hashmap"
	"sync"
)

type ReadWriteMap struct {
	mutex sync.Mutex
	hmap  maps.Map
}

func (rwMap *ReadWriteMap) Clear() {
	rwMap.hmap.Clear()
}

func (rwMap *ReadWriteMap) SetMap(newMap maps.Map) {
	rwMap.lock()
	rwMap.hmap = newMap
}

func (rwMap *ReadWriteMap) lock() {
	rwMap.mutex.Lock()
	defer rwMap.mutex.Unlock()
}

func (rwMap *ReadWriteMap) New() (r ReadWriteMap) {
	return ReadWriteMap{mutex: sync.Mutex{},
		hmap: hashmap.New()}
}
